<?php


//Import Response Class
require_once 'lib/raspuns.php';

//Creating User Class
class Manopere {
	var $simbol;
	var $nume;
	var $um;
	var $pret;

}
//Make DB connection
require_once ('../conexiune_bazadedate.php');
//Query BD
if (isset ($_GET['start']))
	$offset = $_GET['start'];
else
	$offset = 0;

$limit = $_GET['limit'];

$result = mysql_query("SELECT simbol,nume,um,pret FROM manopere LIMIT $offset, $limit");
$totalquery = mysql_query("SELECT COUNT(*) FROM manopere");
$total = mysql_fetch_array($totalquery);
$total = ($total[0]);
$query_array = array ();
$i = 0;
//Iterate all Select
while ($row = mysql_fetch_array($result)) {
	//Create New User instance
	$Manopere = new Manopere();
	//Fetch User Info
	$Manopere->simbol = $row['simbol'];
	$Manopere->nume = $row['nume'];
	$Manopere->um = $row['um'];
	$Manopere->pret = $row['pret'];

	//Add User to ARRAY
	$query_array[$i] = $Manopere;
	$i++;

}
mysql_close($con);

//Creating Json Array needed for Extjs Proxy
$res = new Raspuns();
$res->success = true;
$res->message = "Loaded data";
$res->total = $total;
$res->data = $query_array;
//Printing json ARRAY
print_r($res->to_json());
?>